package com.llap.exp190929.entity;

import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;

/**
 * Created by LLAP on 2019/10/14.
 * Copyright (c) 2019 LLAP. All rights reserved.
 */
@Entity
@Data
@DynamicInsert
@DynamicUpdate
public class CardAccount {
    public static final short DISABLED = 0;
    public static final short ENABLED = 1;

    @Id @Column(length = 16) private String cardNo;
    @Column(length = 6) private String password;
    @Column(precision = 11, scale = 2) private BigDecimal balance = BigDecimal.valueOf(0, 2);
    @Column private Short status = ENABLED;

    public CardAccount eraseCredential() {
        this.password = null;
        return this;
    }
}
